<script type="text/javascript" src="catalog/view/javascript/jquery/new.js"></script>
<style>
  #sidebar{
    margin-bottom:5px;
    padding:1px 0;
    -moz-border-radius-topright:5px;
    -moz-border-radius-bottomright:5px;
    -webkit-border-top-right-radius:5px;
    -webkit-border-bottom-right-radius:5px;
    border-top-right-radius:5px;
    border-bottom-right-radius:5px;
    background:#ffffff;
  }
  #sidebar h3{
    padding-left:30px;
  }
  .sidelist{
    position:relative;
    z-index:1;
    height:32px;
    width:210px;
    line-height:32px;
    margin:5px 0;
    background:url(catalog/view/theme/default/images/left_dt.png) repeat-y left;
  }
  .sidelist span h3{
    position:relative;
    z-index:2;
    height:32px;
    font-size:18px;
    color:#ffffff;
    -moz-text-shadow: 0 2px 3px rgba(0,0,0,.5); 
    -webkit-text-shadow: 0 2px 3px rgba(0,0,0,.5); 
    text-shadow: 0 2px 3px rgba(0,0,0,.5); 
    background:url(catalog/view/theme/default/images/left_bar_icon.png) left center no-repeat;
  }
  .sidelist span h3 a{
    font-size:18px;
    text-decoration:none;
    display:block;
    width:190px;
    height:32px;
    color:#fff;

  }
  .sidelist span h3 a:hover{
    color:#fff;
    background:#e32118;
    width:190px;
  }
  .i-list{
    display:none;
    position:absolute;
    z-index:1;
    left:220px;
    top:-20px;
    padding:5px 15px;
    background:#effaff;
    border:1px solid #486f88;
  }
  .i-list ul li{
    width:180px;
    list-style:none;
    line-height:25px;
    overflow: hidden;
    heignt:25px;
  }
  .i-list ul li a{
    color:#333;
    text-decoration:none;
    font-size:13px;
  }
  .i-list ul li a:hover{
    color:#e32117;
  }
  .i-list .second{
    float:left;
    width: 180px;
    overflow: hidden;
    margin: 8px 3px;
    padding: 0 3px;
  }
  .i-list .line{
    width: 1px;
    height: auto;

  }
  .hover{
    border-right:0;
    width:190px;
    background:#fff;
  }
  .third_child{
    margin-left: 5px;
    line-height: 15px;
  }

  .third_child li a{
    
  }
</style>
<div class="leftBar">
  <div id="sidebar">
    <?php if ($categories) { ?>
    <?php foreach ($categories as $categorie) { ?>
    <div class="sidelist">
      <span>
        <h3>
          <a style="color:#ffffff" href="<?php echo $categorie['href']; ?>
            ">
            <?php echo $categorie['name']; ?></a>
        </h3>
      </span>
      <?php if(is_array($categorie['children'])&&count($categorie['children'])>
      0){ ?>
      <div class="i-list" id="cat_<?php echo $categorie['id']; ?>
        ">
        <ul class="second">
          <?php foreach ($categorie['children'] as $cat) { $i++;?>
          <li>
            <a href="<?php echo $cat['href']; ?>
              ">
              <?php echo $cat['name']; ?></a>
            <?php if(is_array($cat['children'])&&count($cat['children'])>
            0) { ?>
            <ul class="third_child">
              <?php foreach ($cat['children'] as $ca) { $j++; ?>
              <li>
                <a href="<?php echo $ca['href']; ?>
                  " style="color: #888;">
                  <?php echo $ca['name']; ?></a>
              </li>
              <?php } ?></ul>
            <?php } ?></li>
          <?php if($cat['break']) { ?></ul>
        <ul class="second" style="border-left: 1px solid #CCC;">
          <?php } ?>
          <?php } ?></ul>
      </div>
      <script type="text/javascript">
              $(document).ready(function(){
                $("#cat_<?php echo $categorie['id']; ?>").css("width",<?php echo $categorie['width']; ?>);
              })
            </script>
      <?php }?></div>
    <?php } ?>
    <?php } ?></div>
  <div class="left_02">
    <div>
      <dt>Inkjet & Toner Finder</dt>
    </div>    
    <ul class="ul_02">
      <li>
        <select name="search_top" id="search_top" onchange="change_search('sec',this.value)">
          <option value=0>-----Select------</option>
          <option value="0" disabled=true>---Inkjet Cartridges---</option>
          <?php foreach ($inkjets as $inkjet) { ?>
          <option value="<?php echo $inkjet['category_id'];?>"><?php echo $inkjet['name'];?></option>
          <?php } ?>
          <option value="0" disabled=true>---Toner Cartridges---</option>
          <?php foreach ($toners as $toner) { ?>
          <option value="<?php echo $toner['category_id'];?>"><?php echo $toner['name'];?></option>
          <?php } ?>
        </select>
      </li>
      <li>
        <select name="search_sec" id="search_sec" onchange="change_search('thr',this.value)">
          <option value=0>-----Select------</option>
        </select>
      </li>
      <li>
        <select name="search_thr" id="search_thr">
          <option value=0>-----Select------</option>
        </select>
      </li>
      <li>
        <button onclick="search_up()" style="cursor:pointer;width: 131px; height: 30px; background: url('catalog/view/theme/default/images/btn_04.png') repeat scroll 0px 0px transparent;">Search</button>
      </li>
    </ul>
  </div>
  <div class="left_02">
    <div>
      <dt>Reasons to Shop with us</dt>
    </div>
    <ul class="ul_01">
      <?php foreach($shop_reason as $v){ ?>
      <li>
        <?php echo $v['content'];?></li>
      <?php }?></ul>
  </div>
  <div class="left_02">
    <div>
      <dt>
        <a href="index.php?route=product/special/oth&type=is_best" style="color: #CE6512;">Best Sales</a>
      </dt>
    </div>
    <ul class="ul_02">
      <?php foreach ($on_sales as $on_sale) { ?>
      <li style="height:65px ">
        <a href="<?php echo $this->
          url->link('product/product', 'product_id=' . $on_sale['product_id']);?>" title="
          <?php echo $on_sale['old_name']?>
          ">
          <img style="float:left;margin-right: 5px;" src="<?php echo $on_sale['image']; ?>
          " >
          <p style="padding:10px;vertical-align: middle;">
            <?php echo $on_sale['name'];?>
            <br>
            <?php if (!$on_sale['discount_per']) { ?> <font class="price-font"><?php echo $on_sale['price']; ?></font>
            <?php } else { ?>
            <span class="price-old">
              <?php echo $on_sale['price']; ?></span>
            <span class="price-new">
              $
              <?php echo round($on_sale['special'],2); ?></span>
            <?php } ?></p>
        </a>
      </li>
      <?php } ?></ul>
  </div>
  <div class="left_02">
    <div>
      <dt>
        <a href="http://blog.mallplus.ca" target="_blank" style="color: #CE6512;">BLOG</a>
      </dt>
    </div>
    <ul class="ul_03">
      <?php foreach($blogs as $blog){ ?>
      <li>
        <a href="http://blog.mallplus.ca/?p=<?php echo $blog['ID']; ?>
          "  target="_blank" title="
          <?php echo $blog['post_title']; ?>
          ">
          <?php if (strlen($blog['post_title']) >
          25) {echo substr($blog['post_title'], 0, 25) . "..";
    }else{echo $blog['post_title']; }?>
        </a>
      </li>
      <?php } ?></ul>
  </div>
</div>
<script type="text/javascript">
  function change_search(domid,value){
    if(!value){
      alert("Select the right category please!");
    }
    $.get('/index.php?route=product/category/getCategoryInfo',{"parent_id":value},function(data){
      if(data.status){
        var str="";
        for (var i = 0; i < data.result.length; i++) {
          str+="<option value='"+data.result[i].category_id+"'>"+data.result[i].name+"</option>";
        }
        if(domid){
          $('#search_'+domid).append(str);
        }
      }else{
        alert("Select the right category please!");
      }
    },"json")    
  }
  function search_up(){
    var top=$("#search_top").val();
    var sec=$("#search_sec").val();
    var thr=$("#search_thr").val();
    var str ="";
    if(top==0){
      alert("Select the right category please!");
    }else{
      if(sec!=0){
        str=top+"_"+sec;   
        if(thr!=0){
          str+="_"+thr
        }
      }else{
        str=top
      }
    }
    if(str!=""){
      var url="/index.php?route=product/category&path="+str
      window.location.href=url;
    }
    
  }

</script>